﻿<p>
    This example shows the client-side events supported by Telerik Menu for ASP.NET MVC.
</p>
<p>
    The menu has four events:
</p>
<ul>
    <li>
        The <em>OnLoad</em> event is raised when the component is initialized. You can subscribe to that event by using one of the two overloads of the <strong>OnLoad</strong> method. 
        The one accepts Action as an argument - the other accepts a String.
        Use the Action overload to define the event handler inline. Use the String overload
        to specify the name of the JavaScript function which handles the event. The following code shows both options:
<pre class="prettyprint">
&lt;%= Html.Telerik().Menu()
        .Name("Menu")
        .ClientEvents(events => events
            <em>.OnLoad("onLoad")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Menu()
       .Name("Menu")
       .ClientEvents(events => events
       <em>.OnLoad(() => 
       {
        %&gt;
         function(e) {
             //perform required actions here.
         }
        &lt;%
       })</em>
       .Render();
</pre>
    </li>
    <li>
        The <em>OnOpen</em> event is raised when a menu item is opened. You can subscribe to that event by using one of the two overloads of the <strong>OnOpen</strong> method: 
<pre class="prettyprint">
&lt;%= Html.Telerik().Menu()
        .Name("Menu")
        .ClientEvents(events => events
            <em>.OnOpen("onOpen")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Menu()
       .Name("Menu")
       .ClientEvents(events => events
       <em>.OnOpen(() => 
       {
           %&gt;
            function(e) {
                //perform required actions here.
            }
           &lt;%
       })</em>
       .Render();
</pre>
    </li>
    <li>
        The <em>OnClose</em> event is raised when a menu item is closed. You can subscribe to that event by using one of the two overloads of the <strong>OnClose</strong> method: 
<pre class="prettyprint">
&lt;%= Html.Telerik().Menu()
        .Name("Menu")
        .ClientEvents(events => events
            <em>.OnClose("onClose")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Menu()
       .Name("Menu")
       .ClientEvents(events => events
       <em>.OnClose(() => 
       {
           %&gt;
            function(e) {
                //perform required actions here.
            }
           &lt;%
       })</em>
       .Render();
</pre>
    </li>
    <li>
        The <em>OnSelect</em> event is raised when a menu item is selected. You can subscribe to that event by using one of the two overloads of the <strong>OnSelect</strong> method: 
<pre class="prettyprint">
&lt;%= Html.Telerik().Menu()
        .Name("Menu")
        .ClientEvents(events => events
            <em>.OnSelect("onSelect")</em>
        )
</pre>
or
<pre class="prettyprint">
&lt;% Html.Telerik().Menu()
       .Name("Menu")
       .ClientEvents(events => events
       <em>.OnSelect(() => 
       {
           %&gt;
            function(e) {
                //perform required actions here.
            }
           &lt;%
       })</em>
       .Render();
</pre>
    </li>
</ul>